function FormTool(dataJson, formName) {
    this.dataJson = dataJson || {};
    this.form = $(formName ? formName : "form:first");

    this.fill = function() {
        for (var key in this.dataJson) {
            var e = this.form.find("[name=" + key + "]");
            if (e.is("input[type=button]") || e.is("input[type=reset]")) {
                continue;
            } else if (e.is("input")) {
                this.setValue(key, this.dataJson[key]);
            }
        }
        return this;
    };

    this.setValue = function(name, value) {
        this.form.children("[name=" + name + "]").val(value);
        return this;
    };

    // target is _blank, _self, _top, and window name, etc
    this.target = function(target) {
        this.form.attr("target", target);
        return this;
    };

    // need a json with 'preSubmit' function
    this.submit = function(json) {
        if (typeof(json.preSubmit) == "function") {
            if (!json.preSubmit()) {
                return this;
            }
        } else {
            return this;
        }
        this.form.submit();
        return this;
    };

    this.fill();
};
